
public class FormalParam {
	Type type;
	String id;
	int lineNum;
	int charPos;
	
	public FormalParam ( Type type, String id, int line, int charP){
		this.type = type;
		this.id = id;
		this.lineNum = line;
		this.charPos = charP;
	}
	public String toString(){
		String ret = "FormalParam ";
		
		String s = "";
		s += id;
		return ret+ s;
	}
	public void check(String parent) throws SemanticException {
		SymbolTable table = SymbolTable.getInstance();
		if (table.contains(id)) {
			throw new SemanticException("Semantic Error at line " + this.lineNum + " char " + this.charPos + ":\nThe identifier " + id + " has been used before.\nIn: " + Parser.getLineOfCode(this.lineNum));
		}
		Entry e = new Entry(id, type, true, parent);
		e.level = table.getLevel() - 1;
		table.add(e);
		Entry e2 = new Entry(id, type, true, parent);
		table.add(e2);
		
	}
}
